//package com.cenntro.common.mongdb;
//
//import org.springframework.data.mongodb.core.MongoTemplate;
//
//import com.cenntro.common.util.ApplicationContextUtil;
//import com.mongodb.BasicDBObject;
//
//import ch.qos.logback.classic.spi.ILoggingEvent;
//import ch.qos.logback.core.UnsynchronizedAppenderBase;
//
//public class MongoDBAppender extends UnsynchronizedAppenderBase<ILoggingEvent> {
//
//	public MongoDBAppender() {
//		super.setName("loggingEvents");
//	}
//
//	protected void append(ILoggingEvent eventObject) {
//		MongoTemplate mongoTemplate = ApplicationContextUtil.getBean(MongoTemplate.class);
//		if (mongoTemplate != null) {
//			final BasicDBObject doc = new BasicDBObject();
//			doc.append("level", eventObject.getLevel().toString());
//			doc.append("logger", eventObject.getLoggerName());
//			doc.append("thread", eventObject.getThreadName());
//			doc.append("message", eventObject.getFormattedMessage());
//			mongoTemplate.insert(doc, "log");
//		}
//	}
//}
//
//// public class MongoDBAppender extends MongoDBAppenderBase<ILoggingEvent> {
//// public MongoDBAppender() {
//// super("loggingEvents");
//// }
//
//// @Override
//// protected Document toMongoDocument(ILoggingEvent eventObject) {
//// final Document doc = new Document();
////// doc.append("date", new
//// JDateTime(eventObject.getTimeStamp()).toString("YYYY-MM-DD hh:mm:ss"));
//// doc.append("date",new Date());
//// doc.append("source", source);
//// doc.append("level", eventObject.getLevel().toString());
//// doc.append("logger", eventObject.getLoggerName());
//// doc.append("thread", eventObject.getThreadName());
//// doc.append("message", eventObject.getFormattedMessage());
//// if (eventObject.getMDCPropertyMap() != null &&
//// !eventObject.getMDCPropertyMap().isEmpty())
//// doc.append("mdc", eventObject.getMDCPropertyMap());
////// ...
//// return doc;
//// }
//// }